package com.chapter09;

import com.alibaba.druid.pool.DruidDataSourceFactory;
import com.bdqn.util.JDBCUtils;
import com.chapter08.Test04_druid;
import org.apache.commons.dbutils.QueryRunner;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.util.Properties;

public class Test02_QueryRunner {
    public static void main(String[] args) throws Exception {
        // todo 1、创建数据源
        Connection connection = JDBCUtils.getConnection();

        // todo 2、创建QueryRunner对象
        QueryRunner queryRunner = new QueryRunner();

        // todo 3、增删改、查
        // 添加：修改和删除，一样
        String sql = "INSERT INTO grade(`GradeId`,`GradeName`) VALUES(?,?);";
        int i = queryRunner.update(connection, sql, "301", "301");
        if (i > 0) {
            System.out.println("成功");
        }


    }
}
